﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace LED_Editor.Controls {
	public partial class PlaybackZoomAddFramesControl : UserControl {
		public PlaybackZoomAddFramesControl() {
			InitializeComponent();
			AddToAllVisible = true;
		}
		bool isPlaying;

		public bool IsPlaying {
			get { return isPlaying; }
		}
		private void SetPlayPauseButton(bool isPlaying) {
			if (isPlaying) {
				playPauseButton.StateCommon.Back.Image = playPauseImageList.Images[1];
			} else {
				playPauseButton.StateCommon.Back.Image = playPauseImageList.Images[0];
			}
		}

		private void playPauseButton_Click(object sender, EventArgs e) {
			isPlaying = !isPlaying;
			SetPlayPauseButton(isPlaying);
			ControlActionEventArgs args = new ControlActionEventArgs();
			args.ActionType = ActionType.PlayPause;
			OnControlActionPerformed(args);
		}

		public int ScrollValue { get { return kryptonSlider1.Value; } }
		public int Range { get { return kryptonSlider1.Range; } set { kryptonSlider1.Range = value; } }


		private void addToAllTracksButton_Click(object sender, EventArgs e) {
			ControlActionEventArgs args = new ControlActionEventArgs();
			args.ActionType = ActionType.AddToAll;
			OnControlActionPerformed(args);
		}



		public delegate void ControlActionEventHandler(object sender, ControlActionEventArgs args);
		public event ControlActionEventHandler ControlActionPerformed;
		private void OnControlActionPerformed(ControlActionEventArgs args) {
			if (ControlActionPerformed != null) {
				ControlActionPerformed(this, args);
			}
		}

		private void kryptonSlider1_ValueChanged(AC.ExtendedRenderer.Toolkit.KryptonSlider Sender, AC.ExtendedRenderer.Toolkit.KryptonSlider.SliderEventArgs e) {
			Sender.Value = e.NewValue;
			ControlActionEventArgs args = new ControlActionEventArgs();
			args.ActionType = ActionType.Zoom;
			OnControlActionPerformed(args);
		}

		public bool AddToAllVisible {
			get {
				return addToAllTracksButton.Visible;
			}
			set {
				addToAllTracksButton.Visible = value;
			}
		}


	}

	public enum ActionType {
		PlayPause,
		Zoom,
		AddToAll
	}

	public class ControlActionEventArgs : EventArgs {
		public ControlActionEventArgs() {
			Context = string.Empty;
		}
		public ActionType ActionType { get; set; }
		public string Context { get; set; }
	}
}
